% !Mode:: "TeX:UTF-8"
% !TEX program = xelatex
\documentclass[UTF8,winfonts,10pt]{ctexart} 
\usepackage{fontspec,xltxtra,xunicode}
\usepackage{graphicx} 
\usepackage{xeCJK}
\usepackage{listings} 
%代码着色宏包
\usepackage{xcolor} 
\usepackage{ctex}

\setCJKmainfont{微软雅黑}
\setmonofont{微软雅黑}
%windows下英文可使用Consolas，等宽字体
\setmainfont{Arial} 

% --------------------------显示代码的神器-------------start--------------------------------
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{ %
alsolanguage=Java,
alsolanguage= XML,
%背景框
  %framexleftmargin=10mm,
  frame=none,
  backgroundcolor=\color[RGB]{250,250,250}, 
  basicstyle=\footnotesize,        % 这句设置代码的大小
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % 对过长的代码自动换行
  captionpos=bl,                    % sets the caption-position to bottom
  commentstyle=\color{mygreen},    % 浅灰色的注释
  rulesepcolor=\color{red!20!green!20!blue!20},%代码块边框投影为淡青色 
  stringstyle=\color{orange},     % 代码字符串的特殊格式
   %numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
  numberstyle={\color[RGB]{100,100,100}\tiny} ,%设置行号的样式及大小，大小有tiny,scriptsize,footnotesize,small,normalsize,large等  
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
  %keywordstyle=\color{blue},     
  keywordstyle=\color{blue!90}\bfseries, %代码关键字的颜色为蓝色，粗体 
  deletekeywords={...},            % if you want to delete keywords from the given language
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  aboveskip=0em, %代码块边框 
  %frame=single,                    % adds a frame around the code
  frame=shadowbox, %把代码用带有阴影的框圈起来
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  escapeinside=``, % 英文分号中可写入中文
  breakindent=22pt, % 
  %language=Python,                 % the language of the code
  morekeywords={*,...},            % if you want to add more keywords to the set
  numbers=left,                    % 左侧显示行号 往左靠,还可以为right，或none，即不加行号
  numbersep=8pt,                   % 设置行号与代码的距离，默认是5pt
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % 不显示代码字符串中间的空格标记
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=1,                    % 若设置为2，则显示行号为1,3,5，即stepnumber为公差,默认stepnumber=1
  tabsize=2,                       % sets default tabsize to 2 spaces
  % 设定中文冲突，断行，列模式，数学环境输入，listing数字的样式  
  extendedchars=false,columns=flexible,mathescape=true  
}
% --------------------------显示代码的神器-------------end--------------------------------

\title{Centos7下安装Mysql5.7(2017完美版)
	\\ [2ex] \begin{large} IDEA + Maven+Spring MVC4 之 Hello World \end{large} }

\author{大于QQ：7327791}
\date{2017.6.1}



\begin{document}
\maketitle

%开启新的一页
\newpage

\subsubsection*{1 下载Mysql rpm}


%\parskip 这个也是空行
\par{
	1.1 百度搜索 Mysql，找到第一个 Mysql，点击 Downloads。\newline
	\begin{center}
		\includegraphics[width=4in]{images/1.1.png}\newline
	\end{center}
}

\par{
	1.2 选择 DOWNLOADS 下面的 Yum Repository。\newline
	\begin{center}
		\includegraphics[width=4in]{images/1.2.png}\newline
	\end{center}
}

\par{
	1.3 点击所需要的版本的 Download。\newline
	\begin{center}
		\includegraphics[width=4in]{images/1.3.png}\newline
	\end{center}
}

\par{
	1.4 复制下载的链接地址 https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm。\newline
	\begin{center}
		\includegraphics[width=4in]{images/1.4.png}\newline
	\end{center}
}

\subsubsection*{2 配置Yum源}

\par{
	2.1 Shell登录Centos7系统。\newline
	\begin{center}
		\includegraphics[width=4in]{images/2.1.png} \newline
	\end{center}
}

\par{
	2.2 进入到要下载的文件夹位置： cd /opt\newline
	\begin{center}
		\includegraphics[width=4in]{images/2.2.png}\newline
	\end{center}
}

\par{
	2.3 执行下载： sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm \newline
	\begin{center}
		\includegraphics[width=4in]{images/2.3.png}\newline
	\end{center}
}

\par{
	2.4 安装Mysql源： yum -y localinstall mysql57-community-release-el7-11.noarch.rpm\newline
}

\par{
	2.5 检查Mysql源是否安装成功：yum repolist enabled | grep "mysql.*-community.*" 。这条命令根据电脑配置执行的速度各异，请耐心等待一下。\newline
	\begin{center}
		\includegraphics[width=4in]{images/2.5.png}\newline
	\end{center}
}


\subsubsection*{3 安装MySQL}

\par{
	3.1 执行安装Mysql： yum -y install mysql-community-server\newline
	\begin{center}
		\includegraphics[width=4in]{images/3.1.png}\newline
	\end{center}
}

\par{
	3.2 启动Mysql生成临时密码：systemctl start mysqld \newline
}

\par{
	3.3 到日志中找出数据的初始密码： grep 'temporary password' /var/log/mysqld.log \newline
	\begin{center}
		\includegraphics[width=4in]{images/3.3.png}\newline
	\end{center}
}


\subsubsection*{4 修改Mysql默认密码}

\par{
	4.1 执行：mysql -uroot -p，输入1.3.3中查到的密码，看下面的图，表示你已经用初始密码登录成功了 。\newline
	\begin{center}
		\includegraphics[width=4in]{images/4.1.png}\newline
	\end{center}
}

\par{
	4.2 修改root用户的密码为 ABCabc123! （为了安全起见，密码最好是大写、小写、数字、特殊字符组成，否则mysql会提示密码不符合安全规则）： ALTER USER 'root'@'localhost' IDENTIFIED BY 'ABCabc123!'; 。\newline
	\begin{center}
		\includegraphics[width=4in]{images/4.2.png}\newline
	\end{center}
}

\par{
	4.3 开启远程登录的权限。
	\begin{description}
	\setlength{\itemsep}{0pt}
	\setlength{\parsep}{0pt}
	\setlength{\parskip}{5pt}
	\item\hspace{1.1cm} a. mysql> use mysql;
	\item\hspace{1.1cm} b. mysql> update  user set Host='\%' where User='root' and Host='localhost';
	\item\hspace{1.1cm} c. 退出， mysql> exit;
\end{description}
}
\par{
	4.4 设置开机自动启动Mysql。
	\begin{description}
		\setlength{\itemsep}{0pt}
		\setlength{\parsep}{0pt}
		\setlength{\parskip}{5pt}
		\item\hspace{1.1cm} a. systemctl enable mysqld
		\item\hspace{1.1cm} b. systemctl daemon-reload
		\item\hspace{1.1cm} c. systemctl restart mysqld
	\end{description}
	\begin{center}
		\includegraphics[width=4in]{images/4.4.png}\newline
	\end{center}
}


\subsubsection*{5 远程连接测试}

\par{
	5.1 输入IP，帐号，密码，连接测试，看到如下图则表示你已经成功安装了Mysql数据库了。\newline
	\begin{center}
		\includegraphics[width=4in]{images/5.1.png}\newline
	\end{center}
}

\par{
	5.2 如果此时远程连接不上，请运行命令关闭防火墙：systemctl stop firewalld.service。\newline
	\begin{center}
		\includegraphics[width=2.5in]{images/5.2.png}\newline
	\end{center}
}


\end{document}


